package util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.Iterator;
import java.util.Set;

/**
 * Util class which allow a comparison of {@link Set} classes.
 * 
 * @author Michel & Vincent
 *
 * @param <T>
 */
public class SetComparator<T> {

	/**
	 * Compare two set. Ensure that the two set have the same size and all of objects in
	 * the first set are equals than one of those in the second set.
	 * @param set1
	 * @param set2
	 */
	public void compare(Set<T> set1, Set<T> set2) {
		assertEquals(set1.size(), set2.size());
		Iterator<T> ite1 = set1.iterator();
		while(ite1.hasNext()) {
			T object1 = ite1.next();
			assertTrue(set2.contains(object1));
		}
	}
}
